package WorkTask;

public class GamePlay {
    public static void play(Gamer gamer){
        gamer.player();

    }
    public void starGame(){
        int[][] arr = new int[16][16];
        SetChessPrint.chessPrint(arr);//初始化棋盘
        boolean flag = true;
        int i = 0;//用于记录游戏轮数
        while (true) {
            if (flag == true){
                System.out.println("请白方落子！");
                System.out.println("白方第" + (i + 1) + "子");
                GamePlay.play(new GamerWhite());
                judge(new GamerWhite());
                flag = !flag;
            }else if (flag == false){
                System.out.println("请黑方落子！");
                System.out.println("黑方第" + (i + 1) + "子");
                GamePlay.play(new GamerBlack());
                judge(new GamerBlack());
                i++;
                flag = !flag;
            }
            if (i >= 5){//判断是否获胜的时候游戏的轮数至少为5
                System.out.println("游戏轮数为" + i);
                gameEnd();
                break;
            }

        }
    }
    public void judge(Gamer gamer){
            gamer.show();
    }

    public void gameEnd(){
        System.out.println("游戏结束！");
    }
}
